<%@ page import="java.time.Instant" %><%--
  Created by IntelliJ IDEA.
  User: lzy
  Date: 18-8-2
  Time: 下午3:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" session="false" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    // 获取session对象
    HttpSession session = request.getSession(true);
    out.print(session);

%>
<br>
<%
    out.print(Instant.now());
    out.print("<br/>");

    // 默认过期时间是1800s
    session.setMaxInactiveInterval(5);
    out.print(session.getMaxInactiveInterval());

    // 使当前的session对象失效
//    session.invalidate();
%>

<%--<%= session.getId()%>--%>
<%--<%--%>
<%--Cookie cookie = new Cookie("JSESSIONID", session.getId());--%>
<%--cookie.setMaxAge(20);--%>
<%--response.addCookie(cookie);--%>
<%--%>--%>
</body>
</html>
